﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>Index</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="~/Resources/mainFrame/css/bootstrap.min14ed.css" rel="stylesheet">
    <link href="~/Resources/mainFrame/css/font-awesome.min93e3.css" rel="stylesheet">
    <link href="~/Resources/mainFrame/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="~/Resources/mainFrame/css/animate.min.css" rel="stylesheet">
    <link href="~/Resources/mainFrame/css/style.min862f.css" rel="stylesheet">
    <!--treeview需要的css-->
    <link href="~/Resources/mainFrame/css/plugins/treeview/bootstrap-treeview.css" rel="stylesheet">
    <link href="~/Resources/css/BootTableHelp/pagination.css" rel="stylesheet" />
    <style>
        #add_area .form-group {
            margin-left: 0px;
            margin-right: 10px;
        }
        #add_area .hr-line-dashed {
            margin-top: 2px;
            margin-bottom: 2px;
        }
    </style>
</head>
<body class="panel-body" style="padding:5px;">
    <div class="row">
        <div id="divTree" class="col-sm-2" style="overflow:auto; margin:0;">
            <div id="treeview"></div>
        </div>
        <div class="col-sm-10">
            <div class="example">
                <table id="TableFromData" data-mobile-responsive="true"></table>
            </div>
        </div>
    </div>

    <div id="shop_tool" class="row">
        <input id="NodeUnitID" type="hidden" name="name" value="" />
        <div class="col-sm-5" style="padding:0;">
            <div class="input-group">
                <input id="hi_code_id" type="hidden" />
                <input id="hi_item_id" type="hidden" />
                <span class="input-group-btn">
                    <input type="text" id="txtSearchName" class="form-control" placeholder="字典值">
                    <button type="button" id="btnSearch" class="btn btn-primary">
                        <i class="glyphicon glyphicon-search"></i>
                        查询
                    </button>
                    @{
                        List<string> folderList = (List<string>)ViewBag.elementList;
                        if (folderList.Contains("addItemCode"))
                        {
                            <button type="button" id="addItemCode" class="btn btn-primary" style="margin-left: 2px;">
                                <i class="glyphicon glyphicon-plus"></i>
                                新增
                            </button>
                        }
                        <button type="button" id="btnUpLogo" class="btn btn-primary" style="margin-left: 2px;">
                            <i class="glyphicon glyphicon-circle-arrow-up"></i>
                            上传Logo
                        </button>
                        <button type="button" id="refreshCode" class="btn btn-primary" style="margin-left: 2px;">
                            <i class="glyphicon glyphicon-refresh"></i>
                            刷新导航树
                        </button>
                    }
                </span>
            </div>
        </div>
    </div>

    <div id="add_area" style="display:none;" class="col-sm-12">
        <div class="row form-horizontal">
            <div class="hr-line-dashed"></div>
            <div class="form-group">
                <label class="col-sm-2 control-label">名称<i class="glyphicon glyphicon-asterisk" style="color:red;"></i></label>
                <div class="col-sm-4">
                    <input type="text" id="item_name" class="form-control" placeholder="名称" />
                </div>
                <label class="col-sm-2 control-label">代码<i class="glyphicon glyphicon-asterisk" style="color:red;"></i></label>
                <div class="col-sm-4">
                    <input type="text" id="item_code" class="form-control" placeholder="代码" />
                </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
                <label class="col-sm-2 control-label">英文名称</label>
                <div class="col-sm-4">
                    <input type="text" id="enLang" class="form-control" placeholder="英文名称" />
                </div>
                <label class="col-sm-2 control-label">所属类别</label>
                <div class="col-sm-4">
                    <input type="text" id="code_type" name="code_type" class="form-control" placeholder="所属类别" />
                </div>
            </div>
            <div class="hr-line-dashed"></div>
            <div class="form-group">
                <label class="col-sm-2 control-label">备注</label>
                <div class="col-sm-10" style="padding-left:15px; padding-right:15px;">
                    <textarea id="item_note" name="comment" class="form-control" placeholder="备注"></textarea>
                </div>
            </div>
            <div class="hr-line-dashed"></div>
        </div>
    </div>
    <!--Logo图片-->
    <div id="orgLogo" style="width: 460px; overflow: hidden; display: none;">
        <form class="form-horizontal m-t" id="orgLogoForm" method="post" enctype="multipart/form-data" style="padding-bottom:20px;">
            <div class="form-group">
                <label class="col-sm-3 control-label">logo<span class="glyphicon glyphicon-asterisk requiredtitle"></span>：</label>
                <div class="col-sm-7">
                    <input type="file" id="logo_img" name="logo_img" placeholder="请选择logo图片的" class="form-control" required="" aria-required="true">
                </div>
            </div>
        </form>
    </div>

    <script src="~/Scripts/jquery-1.10.2.min.js"></script>
    @Scripts.Render("~/bundles/mainScript")
    @Scripts.Render("~/bundles/bootstrap-table")
    @Scripts.Render("~/bundles/TreeViewItem")
    <script src="~/Resources/mainFrame/js/jquery.form.min.js"></script>
    <!--引入bootstrap-table-help.JS文件。该文件包含一个table基类-->
    <script src="~/Scripts/bootstrap-table-help.js"></script>
    <script src="~/Scripts/bootstrap-tree-help.js"></script>
    <script src="~/Scripts/url-help.js"></script>
    <script src="~/Resources/myScript/System/ItemCode.js"></script>
    <script src="~/Resources/layer-3.0.1/layer.js"></script>
    <script src="~/Resources/tools/jquery-hcq2-extend.js"></script>
    <script>
        var treeView;
        $(function () {
            //上传logo
            $('#btnUpLogo').on('click',function(){
                layer.open({
                    title: ['上传logo', 'font-size:18px;'],
                    type: 1,
                    content: $('#orgLogo'),
                    scroll: false,//是否显示滚动条、默认不显示
                    btn: ['确定', '取消'],
                    area: ['480px', '250px'],
                    yes: function (li, o) {
                        var logo_img=$('#logo_img').val();
                        if(!logo_img){
                            layer.alert("请选择logo图片！",{icon:3});
                            return false;
                        }
                        $('#orgLogoForm').ajaxSubmit({
                            url: $.ctx()+'/Main/UploadLogo',
                            type: "post",
                            dataType: "json",
                            beforeSubmit: function (arr, $form, options) {
                                layer.msg("提交数据~", { icon: 1, time: 5000 });
                            },
                            success: function (result, status, xhr, $form) {
                                layer.closeAll();
                                if (result.Statu === 0) 
                                    //更新logo地址
                                    $('#logoUrl', parent.document).attr("src", result.Data.toString().replace("~", $.ctx()));
                                else
                                    layer.alert(result.Msg, { icon: 5 });
                            },
                            error: function (xhr, status, error, $form) {
                                layer.msg("保存失败~", { icon: 5 });
                            }
                        });
                    }
                });
            });
            $("#divTree").height($.GetBodyHeight());
            treeView=treeHelp.BindTree("treeview",@Html.Raw(ViewBag.ItemCodeTree),treeClick,untreeClick);
        });
        function treeClick (o){
            $("#hi_item_id").val(o.item_id);
            $("#hi_code_id").val(o.code_id == undefined || o.code_id=="" || o.code_id==null ? "" : o.code_id);
            tableHelp.refresh(table);
        }
        //取消选择
        function untreeClick(o){
            var sel=$('#treeview').treeview('getSelected');
            if(!sel || sel.length===0){
                $("#hi_item_id").val("");
                $("#hi_code_id").val("");
            }
        }
    </script>
</body>
</html>
